<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
  <meta http-equiv="content-type" content="text/html; charset=utf-8">
  <title></title>
  <script src="../core/conform.js"></script>
  <script>
  var fields = [
    {'name': 'TAX_RATE',     'constant': 0.25},
    {'name': 'QUANTITY',     'set'     : '[1,2,3]'},
    {'name': 'PRICE',        'formula' : ' if(this.cf.QUANTITY < 2) this.cf.PRICE = 10; else this.cf.PRICE = 8;'},
    {'name': 'SUM',          'formula' : ' this.cf.SUM = this.cf.QUANTITY * this.cf.PRICE; '},
    {'name': 'SUM_WITH_TAX', 'formula' : ' this.cf.SUM_WITH_TAX =  this.cf.SUM + this.cf.SUM * this.cf.TAX_RATE '}
  ];
  
  var f = new conform.Form();
  f.load(fields);
  
  var fieldQUANTITY
  window.onload = function(){
    fieldQUANTITY = document.createElement('INPUT');
    fieldQUANTITY.setAttribute('type', 'text');
    fieldQUANTITY.setAttribute('value', 1);
    fieldQUANTITY.addEventListener("change", function(){
      f.QUANTITY = this.value;
      f._recalc();
      console.log(f.SUM_WITH_TAX);
    }, false);
    document.getElementById('playground').appendChild(fieldQUANTITY)
  }
  </script>
  </head>
  <body>
    <div id="playground"></div>
  </body>
</html>